package com.sgb.kjwl.view.widget;

import android.content.Context;

import androidx.recyclerview.widget.GridLayoutManager;

import com.sgb.kjwl.R;
import com.swgk.core.view.entity.MenuEntity;
import com.sgb.kjwl.view.ui.adapter.home.HomeGoodsChooseListAdapter;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;

import java.util.List;

public class HomeGoodsSelectionTypePopWindow extends BasePopWindow {

    private HomeGoodsChooseListAdapter homeGoodsChooseListAdapter;

    public HomeGoodsSelectionTypePopWindow(Context context) {
        super(context);
    }
    @Override
    protected int popLayout() {
        return R.layout.popwindow_goods_types;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        MaxHeightRecyclerView recyclerView = holder.getPop().findViewById(R.id.type_list);
        homeGoodsChooseListAdapter = new HomeGoodsChooseListAdapter(mContext, null);
        homeGoodsChooseListAdapter.setItemSelect(true);
        homeGoodsChooseListAdapter.setDefItem(-1);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext, 4));
        recyclerView.setAdapter(homeGoodsChooseListAdapter);
        homeGoodsChooseListAdapter.setOnItemClick(new AdapterOnItemClick<MenuEntity>() {
            @Override
            public void onItemClick(MenuEntity provinceEntity, int position) {
                onResultClick.result(provinceEntity, position, null);
                dissMiss();
            }
        });

    }

    public void setData(List<MenuEntity> dictdata) {
        homeGoodsChooseListAdapter.setDatas(dictdata);
    }

    public void setDefItem(int position) {
        homeGoodsChooseListAdapter.setDefItem(position);
    }
}
